﻿@using ZealousTTS.Web.Utility;
@using ZealousTTS.Common.Extensions;
@{
    bool showEditLink = false;
    String linkTarget = String.Empty;
    if(ViewBag.ShowEditLink != null && Convert.ToBoolean(ViewBag.ShowEditLink) == true)
    {
        showEditLink = true;
        linkTarget = " target=\"_blank\"";
    }
    System.Data.DataSet ds = ViewBag.DataSource as System.Data.DataSet;
    int totalRecord = (int)ViewBag.TotalRecord;
    int[] ProductCompareList = (from P in SessionCache.ProductCompareList select P.ID).ToArray();
}

@if (totalRecord > 0)
{
    int loopCounter = 0;
    <div class="product_description">
    @foreach (System.Data.DataRow product in ds.Tables[0].Rows)
    {
        int productID = Convert.ToInt32(product["ID"]);
        String compareClass = ProductCompareList.Contains(productID) ? "product-compared-link-button" : "product-compare-link-button";
        String compareText = compareClass == "product-compared-link-button" ? "Compared" : "Compare";
        loopCounter++;        
        <div class="features">
            <div class="image-checkbox">
                <div class="image">
                    @*<img src="/Content/Images/computer.png" alt="" title="" />*@
                    @if (product["Thumbnail"] == null)
                    {
                        @:<img src="@AppConstants.Directories.PRODUCT_IMAGES/NoProduct.gif" alt="" title="@product["Name"]" />
                    }
                    @*ViewBag.DataSource*@
                    else
                    {
                        @:<img src="@AppConstants.Directories.PRODUCT_IMAGES/@product["Thumbnail"]" alt="@product["Thumbnail"]" title="@product["Name"]" />
                    }
                </div>
                <div class="checkbox">
                    @if(compareClass == "product-compared-link-button"){
                        <span class="@compareClass">@compareText</span>
                    }
                    else{
                        @*<input id="chkCompare@(loopCounter)" type="checkbox" value="@product["ID"]" name=""/><label for="chkCompare@(loopCounter)">Compare</label>*@
                        <a class="@compareClass" href="javascript:void(0);" onclick="AddToProductCompare(@productID, this);">@compareText</a> 
                    }
                    @if (showEditLink)
                    {
                        @Html.PrivateLink("Edit", "Edit/" + productID, "Product")
                    }
                </div>                
            </div>
            <div class="details-block">
                <div class="details_top">
                    <h3><a href="/product/details/@(productID)/@(product["ProductUrl"])"@linkTarget >@product["Name"]</a></h3>@*<h3>Apple Macbook Pro 15" Screen Core-I7 4GB DDR3 Ram</h3>*@
                    <h4>@product["Company"] @*Computer Source Update 4 Days ago*@</h4>
                </div>
                <div class="details">@product["Description"] @*Quade core intel I7,2GH2 4GB,DDR3 RAM,500GB HDD Intel HD & AMD Redon*@</div>
            </div>
            <div class="price-block">
                <div>
                    <h4>Price</h4>
                    <h5>@Html.FormatData(product["Price"])</h5> <span class="currency">@ConfigReader.CurrencyCode</span>
                </div>
                <div class="offer-block"><img src="/Content/Images/noStock_tag.png" alt="" title="" /></div>
            </div>
            <div class="clear"></div>
        </div>
    } 
    </div>   
}
else
{
    @Html.InfoMessageBox("No Product Found.")
}

